package com.ccm.demo.activemq.controller;

import com.alibaba.fastjson.JSON;
import com.ccm.demo.activemq.entity.User;
import org.springframework.jms.core.JmsTemplate;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class HelloWorldController {

	@Resource
	private JmsTemplate jmsTemplate;

	@RequestMapping("sendMQ")
	public String sendMQ(String message){
		User admin = new User("admin", "123456");
		String json = JSON.toJSONString(admin);
		jmsTemplate.send("myDestination", session -> session.createTextMessage(json));
		return "ok";
	}
}
